package com.eip.zd.controller;

import com.eip.zd.common.Result;
import com.eip.zd.entity.Project;
import com.eip.zd.service.ProjectService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/project")
public class ProjectController {
    @Resource
    private ProjectService projectService;

    @GetMapping("/getProjectList1")
    public Result getProjectList1(@RequestParam(required = false) String keyword) {
        List<Project> projectList = projectService.getProjectList1(keyword);
        return Result.success(projectList);
    }
    @GetMapping("/getProjectList2")
    public Result getProjectList2(@RequestParam(required = false) String keyword, @RequestParam(required = false) String custId) {
        List<Project> projectList = projectService.getProjectList2(keyword, custId);
        return Result.success(projectList);
    }
    @PostMapping("/add")
    public Result addProject(@RequestBody Project project) {
        projectService.add(project);
        return Result.success();
    }
    @PostMapping("/update")
    public Result updateProject(@RequestBody Project project) {
        projectService.update(project);
        return Result.success();
    }
    @PostMapping("/remove/{id}")
    public Result removeProject(@PathVariable Long id) {
        projectService.remove(id);
        return Result.success();
    }
    @PostMapping("/ifUse/{id}")
    public Result ifUse(@PathVariable Long id) {
        projectService.ifUse(id);
        return Result.success();
    }
}
